<template lang="html">
  <div class="">

      <div class="app-header ">
        <router-link :to="{path: '/'}">
          <img src="../assets/logo.png" class="logo">
        </router-link>
          <ul class="longin_nav">
            <li>{{userName}}</li>
            <li @click="logClick" v-if="userName === ''">登录</li>
            <li>|</li>
          <router-link :to="{path: '/reg'}">
            <li v-if="userName === ''" :to="{path:'/reg'}">注册</li>
          </router-link>

            <li  v-if="userName !== ''" @click="exit">退出</li>
            <li>|</li>
            <li @click="aboutClick">关于</li>
          </ul>
      </div>
      <div class="app-content">
        <keep-alive>
          <router-view></router-view>
        </keep-alive>
      </div>
      <div class="app-footer">
         <p>© 2016 fishenal MIT</p>
      </div>
      <Dialogs :is-show="isShowAboutDialog" @on-close="closeDialog('isShowAboutDialog')">about</Dialogs>
      <Dialogs :is-show="isShowLogDialog" @on-close="closeDialog('isShowLogDialog')">
        <log-form @has-log="onSuccessLog"></log-form>
      </Dialogs>
      <Dialogs :is-show="isShowRegDialog" @on-close="closeDialog('isShowRegDialog')">
          <reg-form></reg-form>
      </Dialogs>
    </div>
</template>
<script>
import Dialogs from './dialog'
import LogForm from './logForm'
import RegForm from './regForm'
export default {
  components:{
    Dialogs,
    LogForm,
    RegForm
  },
  data() {
    return {
      msg:"welcome vue",
      isShowAboutDialog : false,
      isShowLogDialog: false,
      isShowRegDialog: false,
      userName:''
    };
  },
  methods:{
    aboutClick (){
      this.isShowAboutDialog = true
    },
    logClick () {
      this.isShowLogDialog = true

    },
    regClick () {
      this.isShowRegDialog = true

    },
    closeDialog (attr){
      this[attr]  =  false
    },
    onSuccessLog (data) {
      console.log(data)
      this.userName =data.username
      this.closeDialog('isShowLogDialog')
    },
    exit () {

    }
  }
};
</script>

<style lang="css">
    /* http://meyerweb.com/eric/tools/css/reset/
     v2.0 | 20110126
     License: none (public domain)
    */

    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    b, u, i, center,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td,
    article, aside, canvas, details, embed,
    figure, figcaption, footer, header, hgroup,
    menu, nav, output, ruby, section, summary,
    time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    }
    /* HTML5 display-role reset for older browsers */
    article, aside, details, figcaption, figure,
    footer, header, hgroup, menu, nav, section {
    display: block;
    }
    body {
      background: #f0f2f5;
      font-family: "Helvetica Neue",Helvetica,Arial,"Hiragino Sans GB","Hiragino Sans GB W3","Microsoft YaHei UI","Microsoft YaHei","WenQuanYi Micro Hei",sans-serif;
      font-size: 14px;
      color: #444;
    }
    ol, ul {
    list-style: none;
    }
    blockquote, q {
    quotes: none;
    }
    blockquote:before, blockquote:after,
    q:before, q:after {
    content: '';
    content: none;
    }
    table {
    border-collapse: collapse;
    border-spacing: 0;
    }
    a {
      color: inherit;
      text-decoration: none;
    }
    a:hover{
      text-decoration: none;
      color:#ddd;
    }
    .app-header{
      height: 50px;
      line-height: 50px;
      background-color: #616161;
      color: #fff;
    }
    .app-header .logo{
      width: 50px;
      /*margin-top: 20px;*/
      margin-left: 20px;
      float: left;
    }
    .longin_nav{
      overflow: hidden;
      float: right;
    }
    .longin_nav li{
      float: left;
      margin-right: 20px;
      cursor: pointer;
    }
    .app-footer {
      text-align: center;
      height: 80px;
      width: 100%;
      line-height: 80px;
      background: #e3e4e8;
      clear: both;
      margin-top: 30px;
    }
    .button {
      background: #4fc08d;
      color: #fff;
      display: inline-block;
      padding: 10px 20px;
      cursor: pointer;
    }

    .g-form {

    }
    .g-form-line {
      padding: 15px 0;
    }
    .g-form-label {
      width: 100px;
      font-size: 16px;
      display: inline-block;
    }
    .g-form-input {
      display: inline-block;
    }
    .g-form-input input {
      height: 30px;
      width: 200px;
      line-height: 30px;
      vertical-align: middle;
      padding: 0 10px;
      border: 1px solid #ccc;
    }
    .g-form-btn {
      padding-left: 100px;
    }
    .g-form-error {
      color: red;
      padding-left: 15px;
    }
</style>
